FROM rust:1.81-slim-bullseye

# Install toolchain dependencies required for building bootable Rust kernels.
# Includes build-essential for linking, llvm/clang utilities for rust-lld, and QEMU
# so the container can optionally run integration checks if needed.
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        build-essential \
        clang \
        llvm \
        nasm \
        pkg-config \
        qemu-system-x86 \
        ca-certificates \
        git \
    && rm -rf /var/lib/apt/lists/*

# Prepare the nightly toolchain and components required by bootimage.
RUN rustup toolchain install nightly \
    && rustup component add rust-src llvm-tools-preview --toolchain nightly \
    && cargo +nightly install bootimage

WORKDIR /workspace
